home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / freyja13.exe / lha / JAGUAR.C < prev    next >
C/C++ Source or Header  |  1992-03-22  |  8KB  |  418 lines

  1. /* JAGUAR.C -- HP95LX (Jaguar) Commands and Support
  2.  
  3.     Written July 1991 by Craig A. Finseth
  4.     Copyright 1991 by Craig A. Finseth
  5.  
  6. NOTE: This entire file is only compiled and linked on IBM PC (MSDOS)
  7. systems.  Therefore, no #ifdef's are required.
  8. */
  9.  
  10. #include "freyja.h"
  11.  
  12. /* The following are excerpts from files Copyright 1990 by
  13. Hewlett-Packard and Copyright 1990 by Lotus Development Corporation. */
  14.  
  15. /* ============================================================ */
  16. /*#include "headers/settings.h"*/
  17. #define MAX_MACRO_LEN    256
  18.  
  19. #define NAMEBUFLEN    30
  20. #define TITLEBUFLEN    30
  21. #define COMPANYBUFLEN    28
  22.  
  23. /*  settings */
  24. typedef struct {
  25.     int    Country;    /* */
  26.     int    Volume;     /* 1 speaker volume level 0ffh for off and 0-3 */
  27.     int    Contrast;    /* 2 contrast level 1-5 */
  28.     int    WeekStart;    /* 3 week starts SUNDAY or Monday */
  29.     int    Punctuation;    /* 4 Punctuation format */
  30.     int     Language;    /* two character code for current language */
  31.     int    DateFormat;    /* 6 current date format */
  32.     int    TimeFormat;    /* 7 current time format */
  33.     int    Sort;        /* 8 collating sequence */
  34.     char    PicFile[80];    /* picture file name */
  35.     char    Name_Buff[NAMEBUFLEN];    
  36.     char    Title_Buff[TITLEBUFLEN]; 
  37.     char    Company_Buff[COMPANYBUFLEN]; 
  38.     int     LanguageCount;
  39.     int    LanguagesAvail[6];    /* MAX_LANG */
  40.     char    LanguageMenu[66];    
  41.  
  42.     char    DateSeparator[2]; /* date separator  can be /-. */
  43.     char    TimeSeparator[2]; /* time separator can be :., or h (for hms) */
  44.     char    DateOrder;    /* */
  45.     char    Time24;        /* use 24 hour time? */
  46.  
  47.     char    Currency[16];   /* currency string */
  48.     int    CurrencyFix;   /* prefix or sufix */
  49.  
  50.     int    Keyboard;
  51.     int    PrBaud;     /* printer baud rate */
  52.     int    PrDriver;    /* epson, hp, etc, by code */
  53.     int     PrInterface;    /* com 1, etc  */
  54.     int    SystemRupt;        /* sysmgr interupt number - 60 default */
  55.     int    CodePage;        /* for PC based - 437 or 850 based */
  56.     int    ExitKeyCode;    /* for PC based - active exit key */
  57.     int    MenuKeyCode;    /* for PC based - active menu key */
  58.     int    CharKeyCode;    /* for PC based - active CHAR key toggle */
  59.     int    Alarm[6];
  60. } SETTINGS;
  61.  
  62.  
  63. typedef struct {
  64.     char    MacroFK;       /* MacroFunctionKey Number 1-10 0 for not used */
  65.         unsigned char MacroSize;   /* elements in the macro */
  66.         char    CommentString[38]; /* MacroFunctionKey's Comment line */
  67.     unsigned int MacroBody[MAX_MACRO_LEN];
  68. } MACROHD;
  69.  
  70. /* ============================================================ */
  71. /* #include "headers/interfac.h" */
  72. #define SC_FILE     5
  73. #define SC_DTIME    11
  74.  
  75. #define F_M_GET_SYSDIR    (SC_FILE * 256) + 22
  76. #define m_get_sysdir(a)           \
  77.     c_service(F_M_GET_SYSDIR,(void far *)(a))
  78.  
  79. #define F_M_GET_SETTINGS (SC_DTIME *256) +9
  80. #define m_get_settings(a,b)      \
  81.     c_service(F_M_GET_SETTINGS, (void far *)(a),(void far *)(b))
  82.  
  83. /* ============================================================ */
  84.  
  85.     /* external key definitions */
  86. #define APPT_KEY    0xB000
  87. #define COMM_KEY    0xAC00
  88. #define FILER_KEY    0xA800
  89. #define HPCALC_KEY    0xC000
  90. #define LOTUS_KEY    0xBC00
  91. #define MEMO_KEY    0xB800
  92. #define PHONE_KEY    0xB400
  93. #define SETUP_KEY    0xA400
  94. #define SPACE_KEY    0x3920
  95.  
  96. static MACROHD m;
  97. static int *mac_ptr;
  98. static int mac_len;
  99.  
  100. void J_Char();        /* int which */
  101. void J_DoKey();        /* int key */
  102.  
  103. /* ------------------------------------------------------------ */
  104.  
  105. void
  106. JInit()
  107.     {
  108.     SETTINGS s;
  109.  
  110.     if (c.g.parameter_1 == 'P' && c.g.key_type != 'C' &&
  111.         c.g.key_type != 'S') JInitA();
  112.  
  113.     mac_len = 0;
  114.  
  115.     m_get_settings(&s, &m);
  116.     DSetup(s.WeekStart);
  117. #if !defined(NOCALC)
  118.     USetup(s.Punctuation & 1 ? 0 : 1, s.Punctuation & 2 ? 0 : 1);
  119. #endif
  120.     }
  121.  
  122.  
  123. /* ------------------------------------------------------------ */
  124.  
  125. void
  126. JFini()
  127.     {
  128.     if (c.g.parameter_1 == 'P' && c.g.key_type != 'C' &&
  129.         c.g.key_type != 'S') JFiniA();
  130.     }
  131.  
  132.  
  133. /* ------------------------------------------------------------ */
  134.  
  135. /* Handle the HP95LX's appt key. */
  136.  
  137. void
  138. JAppt()
  139.     {
  140.     J_DoKey(APPT_KEY);
  141.     }
  142.  
  143.  
  144. /* ------------------------------------------------------------ */
  145.  
  146. /* Handle the HP95LX's comm key. */
  147.  
  148. void
  149. JComm()
  150.     {
  151.     J_DoKey(COMM_KEY);
  152.     }
  153.  
  154.  
  155. /* ------------------------------------------------------------ */
  156.  
  157. /* End a redisplay. */
  158.  
  159. void
  160. JDisEnd()
  161.     {
  162.     JLightOn();
  163.     }
  164.  
  165.  
  166. /* ------------------------------------------------------------ */
  167.  
  168. /* Start a redisplay. */
  169.  
  170. void
  171. JDisStart()
  172.     {
  173.     JLightOff();
  174.     }
  175.  
  176.  
  177. /* ------------------------------------------------------------ */
  178.  
  179. /* Handle the HP95LX's filer key. */
  180.  
  181. void
  182. JFiler()
  183.     {
  184.     J_DoKey(FILER_KEY);
  185.     }
  186.  
  187.  
  188. /* ------------------------------------------------------------ */
  189.  
  190. /* Returns the default configuration file directory. DNAME must point
  191. to an FNAMEMAX-sized buffer. */
  192.  
  193. void
  194. JGetDir(dname)
  195.     char *dname;
  196.     {
  197.     m_get_sysdir(dname);
  198.     }
  199.  
  200.  
  201. /* ------------------------------------------------------------ */
  202.  
  203. /* Get a key and handle Jaguar-specific translation. */
  204.  
  205. int
  206. JGetKey()
  207.     {
  208.     int chr;
  209.  
  210. again:
  211.     if (mac_len > 0) {
  212.         mac_len--;
  213.         chr = *mac_ptr++;
  214.         }
  215.     else    chr = JGetKeyA();
  216.  
  217.     if (chr & 0xFF) {    /* regular key */
  218.         chr &= 0xFF;
  219.         return(chr);
  220.         }
  221.     else    {
  222.         chr >>= 8;
  223.         chr &= 0xFF;
  224.         if (chr == 0xC8) chr = 133;
  225.         else if (chr == 0xA4) chr = 134;
  226.         else if (chr == 0xA8) chr = 135;
  227.         else if (chr == 0xAC) chr = 136;
  228.         else if (chr == 0xB0) chr = 137;
  229.         else if (chr == 0xB4) chr = 138;
  230.         else if (chr == 0xB8) chr = 139;
  231.         else if (chr == 0xBC) chr = 140;
  232.         else if (chr == 0xC0) chr = 141;
  233.         else if (chr >= 0xDB && chr <= 0xE4) {
  234.             J_Char(chr - 0xDB + 1);
  235.             goto again;
  236.             }
  237.         return(chr + 0x100);
  238.         }
  239.     }
  240.  
  241.  
  242. /* ------------------------------------------------------------ */
  243.  
  244. /* Handle the HP95LX's HP Calc key. */
  245.  
  246. void
  247. JHPCalc()
  248.     {
  249.     J_DoKey(HPCALC_KEY);
  250.     }
  251.  
  252.  
  253. /* ------------------------------------------------------------ */
  254.  
  255. /* Check for a key press.  Return as KIsKey */
  256.  
  257. char
  258. JIsKey()
  259.     {
  260.     return(mac_len > 0 || JIsKeyA() ? 'Y' : 'N');
  261.     }
  262.  
  263.  
  264. /* ------------------------------------------------------------ */
  265.  
  266. /* Handle the HP95LX's Lotus key. */
  267.  
  268. void
  269. JLotus()
  270.     {
  271.     J_DoKey(LOTUS_KEY);
  272.     }
  273.  
  274.  
  275. /* ------------------------------------------------------------ */
  276.  
  277. /* Handle the HP95LX's memo key. */
  278.  
  279. void
  280. JMemo()
  281.     {
  282.     J_DoKey(MEMO_KEY);
  283.     }
  284.  
  285.  
  286. /* ------------------------------------------------------------ */
  287.  
  288. /* Handle the HP95LX's menu key. */
  289.  
  290. void
  291. JMenu()
  292.     {
  293.     int chr;
  294.     int which = 0;
  295.  
  296.     uarg = 0;
  297.  
  298.     chr = NUL;
  299.     for (;;) {
  300.         DJMenus(which);
  301.         if (chr == CR)
  302.             chr = "HOSQ"[which];
  303.         else    chr = xtoupper(KGetChar());
  304.         switch (chr) {
  305.  
  306.         case 'H':
  307.             HHelp();
  308.             return;
  309.             /*break;*/
  310.  
  311.         case 'O':
  312.             FFileFind();
  313.             return;
  314.             /*break;*/
  315.  
  316.         case 'S':
  317.             FFileSave();
  318.             return;
  319.             /*break;*/
  320.  
  321.         case KEYQUIT:
  322.         case 'Q':
  323.             DJMenus(-1);
  324.             MExit();
  325.             if (doabort) JPushKeyA(0x3920);
  326.             return;
  327.             /*break;*/
  328.  
  329.         case KEYABORT:
  330.         case BEL:
  331.         case ESC:
  332.             DJMenus(-1);
  333.             return;
  334.             /*break;*/
  335.  
  336.         case 0x100 + 75:    /* left arrow */
  337.             --which;
  338.             if (which < 0) which = 3;
  339.             break;
  340.  
  341.         case SP:
  342.         case 0x100 + 77:    /* right arrow */
  343.             ++which;
  344.             if (which > 3) which = 0;
  345.             break;
  346.  
  347.         case CR:
  348.             break;
  349.  
  350.         default:
  351.             TBell();
  352.             break;
  353.             }
  354.         }
  355.     }
  356.  
  357.  
  358. /* ------------------------------------------------------------ */
  359.  
  360. /* Handle the HP95LX's phone key. */
  361.  
  362. void
  363. JPhone()
  364.     {
  365.     J_DoKey(PHONE_KEY);
  366.     }
  367.  
  368.  
  369. /* ------------------------------------------------------------ */
  370.  
  371. /* Handle the HP95LX's setup key. */
  372.  
  373. void
  374. JSetup()
  375.     {
  376.     J_DoKey(SETUP_KEY);
  377.     }
  378.  
  379.  
  380. /* ------------------------------------------------------------ */
  381.  
  382. /* Switch input to the specified function key. */
  383.  
  384. void
  385. J_Char(which)
  386.     int which;
  387.     {
  388.     SETTINGS s;
  389.  
  390.     m.MacroFK = which;
  391.     m_get_settings(&s, &m);
  392.  
  393.     if (which == m.MacroFK) {
  394.         mac_ptr = (int *)(m.MacroBody);
  395.         mac_len = m.MacroSize;
  396.         }
  397.     }
  398.  
  399.  
  400. /* ------------------------------------------------------------ */
  401.  
  402. /* Handle each blue key. */
  403.  
  404. void
  405. J_DoKey(key)
  406.     int key;
  407.     {
  408.     uarg = 0;
  409.     MExit();
  410.     if (doabort) {
  411.         JPushKeyA(SPACE_KEY);
  412.         JPushKeyA(key);
  413.         }
  414.     }
  415.  
  416.  
  417. /* end of JAGUAR.C -- HP95LX (Jaguar) Commands */
  418.